
	var time = "";
	
	$(document).ready(function() {
		var date1 = getCurrentMonthFirst();
		var date2 = getCurrentMonthLast();
		time = date1+"~"+date2;
		$('#applyTime').val(time);
		selectDataList();
	});

	/*function selectDataList() {
	function selectDataList() {
		var dttable = $('#myTable').dataTable();
        dttable.fnClearTable(); //清空一下table
        dttable.fnDestroy(); //还原初始化了的datatable
		$("#thislist").html("");
		$("#myTable").find("tbody").html("");
		$.ajax({
			url: urlcore + "/api/dataReport/findDailyStatement?day="+time,
			type: "get",
			dataType: 'json',
			async:'false',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
        	if(data.success == true) {
        		$.each(data.data, function(i,n) {
        			var repayRecordMoney = n.repayRecordMoney
        			var assessMoney = n.assessMoney;
        			var repayRecordNumber = n.repayRecordNumber;
        			var repayRecordMoneyOverDue = n.repayRecordMoneyOverDue;
        			if (repayRecordMoney == null) {
        				repayRecordMoney = 0
        			}
        			if (assessMoney == null) {
        				assessMoney = 0
        			}
        			if (repayRecordNumber == null) {
        				repayRecordNumber = 0
        			}
        			if (repayRecordMoneyOverDue == null) {
        				repayRecordMoneyOverDue = 0
        			}
        			var str="";
        			if(n.type==1){
        				str="正常日租金";
        			}else if(n.type==2){
        				str="逾期还款";
        			}else if(n.type==3){
        				str="赎金";
        			}
					var thislist =
					'<tr class="footable-even" style="display: table-row;">' +
					'<td class="footable-visible">' + (i+1) + '</td>' +
					'<td class="footable-visible">' + n.gmtTime + '</td>' +
					'<td class="footable-visible">' + n.number + '</td>' +
					'<td class="footable-visible">' + n.price + '</td>' +
					'<td class="footable-visible">' + n.finalMoney + '</td>' +
					'<td class="footable-visible">' + repayRecordNumber + '</td>' +
					'<td class="footable-visible">' + repayRecordMoney + '</td>' +
					'<td class="footable-visible">' + repayRecordMoneyOverDue + '</td>' +
					'<td class="footable-visible">' + assessMoney + '</td>' ;
					'<td class="footable-visible">' + str + '</td>' +
					'<td class="footable-visible">' + n.assessMoney + '</td>' ;
					$('#thislist').append(thislist);
				});
 
			        $('#myTable').DataTable();

			}else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}
			}else if (data.code == 'FAIL'){
				alert(data.msg);
			}

			},
			error: function() {
				alert("服务器异常");
			}
		});
	}*/
	
	function selectDataList() {
		$("#thislist").html("");
		$.ajax({
			url: urlcore + "/api/dataReport/findDailyStatement2?day="+time,
			type: "get",
			dataType: 'json',
			async:'false',
			contentType: "application/json;charset=utf-8",
			success: function(data) {
        	if(data.success == true) {
        		$.each(data.data, function(i,n) {
					var thislist =
					'<tr class="footable-even" style="display: table-row;">' +
					'<td class="footable-visible">' + (i+1) + '</td>' +
					'<td class="footable-visible">' + new Date(n.date).pattern("yyyy-MM-dd") + '</td>' +
					'<td class="footable-visible">' + n.evaluationnum + '</td>' +
					'<td class="footable-visible">' + n.totalRentMoney.toFixed(2) + '</td>' +
					'<td class="footable-visible">' + n.totalPayMoney.toFixed(2) + '</td>' +
					'<td class="footable-visible">' + n.orderSize + '</td>' +
					'<td class="footable-visible">' + n.dayrentMoney.toFixed(2) + '</td>' +
					'<td class="footable-visible">' + n.accessMoney.toFixed(2) + '</td>' +
					'<td class="footable-visible">' + n.overtimeMoney.toFixed(2) + '</td>'+
					'<td class="footable-visible">' + n.orderOvderMoney.toFixed(2) + '</td>'+
					'<td class="footable-visible">' + n.overtimeNum + '</td>'+
					'<td class="footable-visible">' + n.depositSum.toFixed(2) + '</td>';
					$('#thislist').append(thislist);
				});
			}else if (data.code == 'OVERTIME'){
				var thisUrl = window.location.href;
				if (thisUrl.indexOf('login.html') <= -1) {
					top.window.location.href="login.html";
				}
			}else if (data.code == 'FAIL'){
				alert(data.msg);
			}

			},
			error: function() {
				alert("服务器异常");
			}
		});
	}
	






/**
 * 搜索
 */
function searchList(){
	time=$('#applyTime').val().trim();
	selectDataList();
}


//导出表格
function excal() {
	
	var time=$('#applyTime').val();
	
	$.ajax({
		url: urlcore + "/api/dataReport/makeExcle?day=" + time,
		type: "GET",
		dataType: 'json',
		contentType: "application/json;charset=utf-8",
		success: function(data) {
			if(data.success == true) {
				var url1 =  data.data.toString().slice(4);
				location.href="https"+url1;
			} else {
				alert(data.msg);
			}
		},
		error: function() {
			alert("error");
		}
	});
}

